package no.ntnu.fp.handlers;

import java.util.List;

import no.ntnu.fp.handler.Handler;
import no.ntnu.fp.messages.Message;
import no.ntnu.fp.messages.impl.EmployeesFetchedMessage;
import no.ntnu.fp.model.DialogModel;
import no.ntnu.fp.model.Employee;
import no.ntnu.fp.model.LoggedInModel;

public class EmployeesFetchedHandler implements Handler {
	private final DialogModel dialogModel;
	private final LoggedInModel loginModel;
	
	public EmployeesFetchedHandler(DialogModel dialogModel, LoggedInModel loginModel) {
		this.dialogModel = dialogModel;
		this.loginModel = loginModel;
	}

	@Override
	public void handleMessage(Message message) {
		EmployeesFetchedMessage employeesFetchedMessage = 
											(EmployeesFetchedMessage) message;
		List<Employee> emps = employeesFetchedMessage.getEmployees();
		emps.remove(loginModel.getEmployee());
		dialogModel.setEmployees(emps);
	}
}
